/*
 * @Author: your name
 * @Date: 2020-09-04 15:07:27
 * @LastEditTime: 2021-02-04 11:36:00
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \go-admin-ui\src\main.js
 */
import Vue from "vue";

import Cookies from "js-cookie";

import "normalize.css/normalize.css"; // a modern alternative to CSS resets

import Element from "element-ui";
import "./styles/element-variables.scss";

import "@/styles/index.scss"; // global css
import "@/styles/admin.scss";

import App from "./App";
import store from "./store";
import router from "./router";
import permission from "./directive/permission";

import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import {
    parseTime,
    resetForm,
    addDateRange,
    selectDictLabel,
    download
} from "@/utils/costum";

import "./icons"; // icon
import "./permission"; // permission control
import "./utils/error-log"; // error log

import Viser from "viser-vue";
Vue.use(Viser);

import * as filters from "./filters"; // global filters

import Pagination from "@/components/Pagination";
import BasicLayout from "@/layout/BasicLayout";
import uploadImg from "@/components/uploadImg";
import elMap from '@/components/elMap/index.vue';
Vue.component("elMap", elMap);

import VueParticles from "vue-particles";
Vue.use(VueParticles);

import "@/utils/dialog";
import VueAMap from "vue-amap";
Vue.use(VueAMap);
Vue.use(Viser);
VueAMap.initAMapApiLoader({
    key: "d22ef836b4f672b22d0ff53e39aa68eb",

    plugin: [
        "AMap.Autocomplete",

        "AMap.PlaceSearch",

        "AMap.Scale",

        "AMap.OverView",

        "AMap.ToolBar",

        "AMap.MapType",

        "AMap.PolyEditor",

        "AMap.CircleEditor",

        "AMap.Geolocation"
    ], // 默认高德 sdk 版本为 1.4.4

    v: "1.4.4"
});
// 全局方法挂载
Vue.prototype.getDicts = getDicts;
Vue.prototype.getConfigKey = getConfigKey;
Vue.prototype.parseTime = parseTime;
Vue.prototype.resetForm = resetForm;
Vue.prototype.addDateRange = addDateRange;
Vue.prototype.selectDictLabel = selectDictLabel;
Vue.prototype.download = download;

// 全局组件挂载
Vue.component("Pagination", Pagination);
Vue.component("BasicLayout", BasicLayout);
Vue.component("uploadImg", uploadImg);

Vue.prototype.msgSuccess = function(msg) {
    this.$message({ showClose: true, message: msg, type: "success" });
};

Vue.prototype.msgError = function(msg) {
    this.$message({ showClose: true, message: msg, type: "error" });
};

Vue.prototype.msgInfo = function(msg) {
    this.$message.info(msg);
};

Vue.use(permission);

Vue.use(Element, {
    size: Cookies.get("size") || "medium" // set element-ui default size
});

// register global utility filters
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key]);
});

Vue.config.productionTip = false;

new Vue({
    el: "#app",
    router,
    store,
    render: h => h(App)
});
